int maxIter = 256;

// z = x + yi
// z^2 = (x + yi)(x + yi)
//     = x^2 + 2xyi + y^2 i^2
//     = x^2 - y^2 + 2xyi
float2 Sqr(float2 z)
{
	return float2(z.x*z.x - z.y*z.y, 2*z.x*z.y);
}

float MagSqr(float2 z)
{
	return dot(z, z);
}

float3 Mandelbrot(float2 c)
{
	float2 z = 0;
	int iter = 0;
	while (iter < maxIter && MagSqr(z) < 4.0)
	{
		z = Sqr(z) + c;
	}
	return float3(iter, z.x, z.y);
}

float4 HueFromPhaseBrightnessFromIter(float3 m)
{
	return 0;
}

[numthreads(1,1,1)]
void Compute(uint3 group : SV_GroupID,
			 uint3 dispatchThreadId : SV_DispatchThreadID,
			 uint3 groupThreadId : SV_GroupThreadID,
			 uint groupIndex : SV_GroupIndex)
{
}

struct VSInput
{
	float3 Pos : POSITION0;
};

struct VSOutput
{
	float4 Pos : POSITION0;
};

VSOutput PerVertex(VSInput v)
{
	VSOutput p = (VSOutput) 0;
	p.Pos = float4(v.Pos, 1);
	return p;
}

struct PSInput
{
	float4 Color : COLOR0;
	float2 Tex : TEXCOORD0;
};

float4 PerPixel(PSInput p) : COLOR0
{
	float4 color = (float4) 0;
	return color;
}
